import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

import { map } from "rxjs/operators";
@Injectable()
export class QkProfileService {

    constructor(private http: HttpClient) { }

    /**显示人员头像 */
    showAvatar(humanId = 0){
        return this.http.get('/media/api/avatar?id='+humanId).pipe(
            map((res:Response) => res['data'])
        )
    }
    /**头像上传 */
    uploadAvatar(file : any, id = 0){
        return this.http.post('/media/api/uploadavatar?id='+id, file).pipe(
            map((res:Response) => res['data'])
        )
    }
    /**获取人员基本信息 */
    loadHumanInfo(){
        return this.http.get('/system/api/humaninfo/profile').pipe(
            map((res:Response) => res['data'])
        )
    }
    /** 保存人员基本信息 */
    updateProfile(profile : any){
        return this.http.post('/system/api/humaninfo/updateprofile', profile).pipe(
            map((res:Response) => res['data'])
        )
    }
    /** 密码修改 */
    changePassword(profile : any) {
        return this.http.post('/system/api/humaninfo/changePassword', profile).pipe(
            map((res:Response) => res['data'])
        )
    }
}
